package bb.lanxing.lib.devices.ble.ble.services;

//import com.alipay.sdk.packet.d;
import bb.lanxing.lib.devices.ble.ble.base.BaseBleSensorDevice;
import bb.lanxing.lib.devices.ble.ble.base.BaseBleService;
import bb.lanxing.lib.devices.ble.ble.characteristic.BodySensorLocationCharacteristics;
import java.util.UUID;

import bb.lanxing.lib.devices.ble.ble.characteristic.hr.HeartRateMeasurementCharacteristics;
import kotlin.Metadata;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.jvm.internal.Intrinsics;
/* compiled from: HeartRateService.kt */

public final class HeartRateService extends BaseBleService {
    private BodySensorLocationCharacteristics bodySensorLocationCharacteristics;

    public HeartRateService(BaseBleSensorDevice device) {
        super(device);
//        Intrinsics.checkNotNullParameter(device, "device");
    }

    public BodySensorLocationCharacteristics getBodySensorLocationCharacteristics() {
        return this.bodySensorLocationCharacteristics;
    }

    public void setBodySensorLocationCharacteristics(BodySensorLocationCharacteristics bodySensorLocationCharacteristics) {
        this.bodySensorLocationCharacteristics = bodySensorLocationCharacteristics;
    }

    @Override
    public UUID targetUUID() {
        UUID fromString = UUID.fromString("0000180d-0000-1000-8000-00805f9b34fb");
        Intrinsics.checkNotNullExpressionValue(fromString, "fromString(BLEAttributes.BLE_HEART_RATE_SERVICE)");
        return fromString;
    }

    public final class HeartRateService$initialization$1 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        int label;
        Object result;
        final HeartRateService this$0;

        public HeartRateService$initialization$1(HeartRateService heartRateService, Continuation<? super HeartRateService$initialization$1> continuation) {
            super((Continuation<Object>) continuation);
            this.this$0 = heartRateService;
        }

        @Override
        public Object invokeSuspend(Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return this.this$0.initialization(this);
        }
    }
    @Override
    public Object initialization(Continuation<? super Unit> continuation) {
        HeartRateService$initialization$1 heartRateService$initialization$1;
        Object coroutine_suspended;
        int i;
        HeartRateService heartRateService = null;
        BodySensorLocationCharacteristics bodySensorLocationCharacteristics;
        HeartRateService heartRateService2;
        if (continuation instanceof HeartRateService$initialization$1) {
            heartRateService$initialization$1 = (HeartRateService$initialization$1) continuation;
            if ((heartRateService$initialization$1.label & Integer.MIN_VALUE) != 0) {
                heartRateService$initialization$1.label -= Integer.MIN_VALUE;
                Object obj = heartRateService$initialization$1.result;
                coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
                i = heartRateService$initialization$1.label;
                if (i != 0) {
                    ResultKt.throwOnFailure(obj);
                    HeartRateMeasurementCharacteristics heartRateMeasurementCharacteristics = new HeartRateMeasurementCharacteristics(this);
                    heartRateMeasurementCharacteristics.enableNotify();
                    heartRateService$initialization$1.L$0 = this;
                    heartRateService$initialization$1.L$1 = heartRateMeasurementCharacteristics;
                    heartRateService$initialization$1.label = 1;
                    if (delayInPeer(heartRateService$initialization$1) == coroutine_suspended) {
                        return coroutine_suspended;
                    }
                    heartRateService = this;
                } else if (i != 1) {
                    if (i == 2) {
                        heartRateService2 = (HeartRateService) heartRateService$initialization$1.L$1;
                        bodySensorLocationCharacteristics = (BodySensorLocationCharacteristics) heartRateService$initialization$1.L$0;
                        ResultKt.throwOnFailure(obj);
                        heartRateService2.bodySensorLocationCharacteristics = bodySensorLocationCharacteristics;
                        return Unit.INSTANCE;
                    }
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                } else {
                    HeartRateMeasurementCharacteristics heartRateMeasurementCharacteristics2 = (HeartRateMeasurementCharacteristics) heartRateService$initialization$1.L$1;
                    heartRateService = (HeartRateService) heartRateService$initialization$1.L$0;
                    ResultKt.throwOnFailure(obj);
                }
                BodySensorLocationCharacteristics bodySensorLocationCharacteristics2 = new BodySensorLocationCharacteristics(heartRateService);
                bodySensorLocationCharacteristics2.read();
                heartRateService$initialization$1.L$0 = bodySensorLocationCharacteristics2;
                heartRateService$initialization$1.L$1 = heartRateService;
                heartRateService$initialization$1.label = 2;
                if (heartRateService.delayInPeer(heartRateService$initialization$1) != coroutine_suspended) {
                    return coroutine_suspended;
                }
                bodySensorLocationCharacteristics = bodySensorLocationCharacteristics2;
                heartRateService2 = heartRateService;
                heartRateService2.bodySensorLocationCharacteristics = bodySensorLocationCharacteristics;
                return Unit.INSTANCE;
            }
        }
        heartRateService$initialization$1 = new HeartRateService$initialization$1(this, (Continuation<? super HeartRateService$initialization$1>) continuation);
        Object obj2 = heartRateService$initialization$1.result;
        coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
        i = heartRateService$initialization$1.label;
        if (i != 0) {
        }
        BodySensorLocationCharacteristics bodySensorLocationCharacteristics22 = new BodySensorLocationCharacteristics(heartRateService);
        bodySensorLocationCharacteristics22.read();
        heartRateService$initialization$1.L$0 = bodySensorLocationCharacteristics22;
        heartRateService$initialization$1.L$1 = heartRateService;
        heartRateService$initialization$1.label = 2;
        if (heartRateService.delayInPeer(heartRateService$initialization$1) != coroutine_suspended) {
        }
        return coroutine_suspended;
    }
}
